package com.zhujy.bfs;

class TreeNode {
	 int val;
	 TreeNode left;
	 TreeNode right;
	 TreeNode(int x) { val = x; }
}

public class SymmetricTree {
	public boolean twoNodeToCompare(TreeNode left,TreeNode right) {
		if(left ==  null && right == null)
			return true;
		if(left == null || right == null) {
			return false;
		}
		if(left.val != right.val )
			return false;
		return twoNodeToCompare(left.left, right.right) && twoNodeToCompare(left.right, right.left);
	}
	
	public boolean isSymmetric(TreeNode root) {
		if(root == null)
		{
			return true;
		}
		else {
			return twoNodeToCompare(root.left,root.right);
		}
    }
}
